package study1;
/**
 * 多态的学习测试  向上转型
 */
//用法：产生对象时
public class Test {
    public static void main(String[] args) {
        Animal animal = new Animal("动物",0);
        Animal Dog = new Dog("狗",3);
        Animal Cat = new Cat("猫",2);
        animal.eat("食物");
        Dog.eat("狗粮");
        Cat.eat("猫粮");
    }

    //用法：方法返回值
    public  static Animal test(){
        return  new Dog("汪",3);
    }
    //用法 方法参数传递
    public static void fun(Animal animal,String food){
        animal.eat(food);
    }
}
